home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_perl.idb / usr / freeware / catman / p_man / cat3 / strict.Z / strict
Encoding:
Text File  |  1998-10-28  |  3.1 KB  |  133 lines

  1.  
  2.  
  3.  
  4.      ssssttttrrrriiiicccctttt((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))         ssssttttrrrriiiicccctttt((((3333))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       strict - Perl    pragma to restrict unsafe constructs
  10.  
  11.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.           use strict;
  13.  
  14.           use strict "vars";
  15.           use strict "refs";
  16.           use strict "subs";
  17.  
  18.           use strict;
  19.           no strict    "vars";
  20.  
  21.  
  22.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  23.       If no    import list is supplied, all possible restrictions are
  24.       assumed.  (This is the safest    mode to    operate    in, but    is
  25.       sometimes too    strict for casual programming.)     Currently,
  26.       there    are three possible things to be    strict about:  "subs",
  27.       "vars", and "refs".
  28.  
  29.       strict refs
  30.         This generates a runtime error if you use symbolic
  31.         references (see    the _p_e_r_l_r_e_f manpage).
  32.  
  33.             use    strict 'refs';
  34.             $ref = \$foo;
  35.             print $$ref;    # ok
  36.             $ref = "foo";
  37.             print $$ref;    # runtime error; normally ok
  38.  
  39.  
  40.       strict vars
  41.         This generates a compile-time error if you access a
  42.         variable that wasn't declared via use vars, localized
  43.         via my() or wasn't fully qualified.  Because this is
  44.         to avoid variable suicide problems and subtle dynamic
  45.         scoping    issues,    a merely _l_o_c_a_l() variable isn't    good
  46.         enough.     See the my entry in the _p_e_r_l_f_u_n_c manpage and
  47.         the local entry    in the _p_e_r_l_f_u_n_c    manpage.
  48.  
  49.             use    strict 'vars';
  50.             $X::foo = 1;     # ok, fully qualified
  51.             my $foo = 10;     # ok, my() var
  52.             local $foo = 9;     # blows up
  53.  
  54.             package Cinna;
  55.             use    vars qw/ $bar /;    # Declares $bar    in current package
  56.             $bar = 'HgS';        # ok, global declared via pragma
  57.  
  58.         The _l_o_c_a_l() generated a    compile-time error because you
  59.         just touched a global name without fully qualifying
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 10/23/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      ssssttttrrrriiiicccctttt((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))         ssssttttrrrriiiicccctttt((((3333))))
  71.  
  72.  
  73.  
  74.         it.
  75.  
  76.       strict subs
  77.         This disables the poetry optimization, generating a
  78.         compile-time error if you try to use a bareword
  79.         identifier that's not a    subroutine, unless it appears
  80.         in curly braces    or on the left hand side of the    "=>"
  81.         symbol.
  82.  
  83.             use    strict 'subs';
  84.             $SIG{PIPE} = Plumber;    # blows    up
  85.             $SIG{PIPE} = "Plumber";    # just fine: bareword in curlies always    ok
  86.             $SIG{PIPE} = \&Plumber;    # preferred form
  87.  
  88.  
  89.       See the section on _P_r_a_g_m_a_t_i_c _M_o_d_u_l_e_s in the _p_e_r_l_m_o_d_l_i_b
  90.       manpage.
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                        (printed 10/23/98)
  130.  
  131.  
  132.  
  133.